package com.samp.tools.curator;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class CuratorClientUtils {
    private static CuratorFramework client = null;
    private static final String zkhost = "";

    public static CuratorFramework getClient(){
        if( client == null ){
            synchronized (client){
                RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
                client = CuratorFrameworkFactory.newClient(zkhost, retryPolicy);
                client.start();
            }
        }
        return client;
    }

    public static void closeClient(){
        if( client != null ){
            client.close();
        }
    }

}
